//
//  Mediator+My.m
//  JinFuThree
//
//  Created by 爱尚 on 2018/8/29.
//  Copyright © 2018年 毛韶谦. All rights reserved.
//

#import "Mediator+My.h"

NSString *const MyTarget = @"MyAction";
NSString *const MyActionMainViewController = @"mainViewController";
NSString *const MyActionMessageViewController = @"my_MessageViewController";
NSString *const MyActionHaveNewMessage = @"my_HaveNewMessage";
NSString *const MyActionEmptyNewMessage = @"emptyNewMessage";
NSString *const MyActionAdvancedApproveViewController = @"my_AdvancedApproveViewController";
NSString *const MyActionAddBankCardViewController = @"my_AddBankCardViewController";
NSString *const MyActionLoansViewController = @"my_LoansViewController";
NSString *const MyActionInstamentViewController = @"my_InstamentViewController";

NSString *const SystemMessageDidFinishLannuchFuction = @"getMessageStatusWithApplicationFinishLaunchingWithOptionsDataDict:";
NSString *const SystemMessageDidBecomeActiveFunction = @"getMessgaeWhthApplicationDidBecomeActiveWithDataDict:";
NSString *const SystemMessageWillEnterForegroundFunction = @"getMessageWhenApplicationWillEnterForegroundWithDataDict:";
NSString *const SystemMessageApplicationReceiveRemoteNotificationFunction = @"getMessageNumWhenApplicationReceiveRemoteNotificationWithDataDict:";

@implementation Mediator (My)


-(UIViewController*_Nullable)My_mainViewController {
    
    MediatorOptions *options = [MediatorOptions optionsWithTargetName:MyTarget actionName:MyActionMainViewController];
    return [self performWithOptions:options];
}



/**
 得到消息页面

 @return VC
 */
-(UIViewController*_Nullable)My_MessageViewController {
    
    MediatorOptions *options = [MediatorOptions optionsWithTargetName:MyTarget actionName:MyActionMessageViewController];
    return [self performWithOptions:options];
}

/**
 得到添加银行卡页面
 
 @return VC
 */
-(UIViewController*_Nullable)My_AddBankCardViewController {
    
    MediatorOptions *options = [MediatorOptions optionsWithTargetName:MyTarget actionName:MyActionAddBankCardViewController];
    return [self performWithOptions:options];
}


/**
 得到贷款页面
 
 @return VC
 */
-(UIViewController*_Nullable)My_LoansViewController {
    
    MediatorOptions *options = [MediatorOptions optionsWithTargetName:MyTarget actionName:MyActionLoansViewController];
    return [self performWithOptions:options];
}

/**
 得到分期页面
 
 @return VC
 */
-(UIViewController*_Nullable)My_InstamentViewController {
    
    MediatorOptions *options = [MediatorOptions optionsWithTargetName:MyTarget actionName:MyActionInstamentViewController];
    return [self performWithOptions:options];
}




/**
 高级实名认证VC
 
 @return VC
 */
-(UIViewController*_Nullable)My_AdvancedApproveViewController {
    
    MediatorOptions *options = [MediatorOptions optionsWithTargetName:MyTarget actionName:MyActionAdvancedApproveViewController];
    return [self performWithOptions:options];
}


/**
 清空消息红点 进入消息页面时使用
 */
- (void)My_EmptyNewMessage {
    
    MediatorOptions *options = [MediatorOptions optionsWithTargetName:MyTarget actionName:MyActionEmptyNewMessage];
    [self performWithOptions:options];
}

/**
 是否有新消息
 
 @return YES 有
 */
-(BOOL)My_HaveNewMessage {
    
    MediatorOptions *options = [MediatorOptions optionsWithTargetName:MyTarget actionName:MyActionHaveNewMessage];
    return [[self performWithOptions:options] boolValue];
}



-(void)getMessageStatusWithApplication:(nonnull UIApplication *)application didFinishLaunchingWithOptions:(nullable NSDictionary *)launchOptions {
    MediatorOptions *options = [MediatorOptions optionsWithTargetName:MyTarget actionName:SystemMessageDidFinishLannuchFuction];
    if (launchOptions == nil) {
        launchOptions = @{};
    }
    options.parameters = @{@"Application":application,@"options":launchOptions};
    [self performWithOptions:options];
}
-(void)getMessgaeWhthApplicationDidBecomeActive:(nonnull UIApplication *)application {
    MediatorOptions *options = [MediatorOptions optionsWithTargetName:MyTarget actionName:SystemMessageDidBecomeActiveFunction];
    options.parameters = @{@"Application":application};
    [self performWithOptions:options];
}
-(void)getMessageWhenApplicationWillEnterForeground:(nonnull UIApplication *)application {
    MediatorOptions *options = [MediatorOptions optionsWithTargetName:MyTarget actionName:SystemMessageWillEnterForegroundFunction];
    options.parameters = @{@"Application":application};
    [self performWithOptions:options];
}
-(void)getMessageNumWhenApplication:(nonnull UIApplication *)application didReceiveRemoteNotification:(nullable NSDictionary *)userInfo window:(nonnull UIWindow *)window {
    MediatorOptions *options = [MediatorOptions optionsWithTargetName:MyTarget actionName:SystemMessageApplicationReceiveRemoteNotificationFunction];
    if (userInfo == nil) {
        userInfo = @{};
    }
    options.parameters = @{@"Application":application,@"options":userInfo,@"window":window};
    [self performWithOptions:options];
}


@end
